import 'package:dynamic_forms/dynamic_forms.dart';

import 'form_field_list.dart';

class FormFieldListParser extends ElementParser<DyFormFieldList> {
  @override
  String get name => "formFieldList";

  @override
  DyFormFieldList parse(
      ParserNode parserNode, FormElement parent, ElementParserFunction parser) {
    var formFieldList = DyFormFieldList();
    formFieldList.fillFormFieldList(
      id: parserNode.getPlainStringValue("id"),
      isVisible: parserNode.getIsVisible(),
      parent: parserNode.getParentValue(parent),
      children: parserNode.getChildren<FormElement>(
          parent: formFieldList,
          parser: parser,
          childrenPropertyName: DyFormFieldList.childrenPropertyName,
          isContentProperty: true),
      attribute:
      parserNode.getStringValue(DyFormFieldList.attributePropertyName),
    );
    return formFieldList;
  }
}
